473,440 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,440 software developers and data experts.

RE: Dynamically populating a drop down list.

Hi Folks,

I have designed a dynamic drop down list but having problems since it is not working as intended. Please help

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <Script language="Javascript">
  4.  
  5. var Select = new Array("-----");
  6.  
  7. var test = (
  8. "Select",
  9. "ITEM 1",
  10. "ITEM 2",
  11. "ITEM 3",
  12. "ITEM 4");
  13.  
  14. var test 1("Select",
  15. "Product 1",
  16. "Product 2",
  17. "Product 3",
  18. "Product 4");
  19.  
  20. function swap(the_array_name)
  21. {
  22. var numbers_select = window.document.Formname.Product;
  23. var the_array = eval(the_array_name);
  24. setOptionText(window.document.Formname.Product,the_array);
  25. }
  26.  
  27. function setOptionText(the_select, the_array)
  28. {
  29. var c;
  30. the_select.length=the_array.length;
  31. for (c=0; c < the_array.length; c++)
  32.     {
  33.     the_select.options[c].text = the_array[c];
  34.     }
  35. }
  36. </script>
  37. <form name="Formname">
  38. <tr><td>
  39. <select name="item" onchange="swap(window.document.Formname.item.options[selectedIndex].value);">
  40. <option value="1">Test</option>
  41. <option value="2">Test 1</option>
  42. </select>
  43.  
  44. <select name="Product">
  45. <option selected>Select</option>
  46. </select>
  47. </form>
  48. </html>
  49. <form name
The above is the rough code like what i am trying to achieve. Please help me with this subject.

Thanks in advance!!

Chandhseke
Dec 11 '09 #1
1 2181
Dormilich
8,658 Expert Mod 8TB
how to define an Array.
Dec 12 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Gurry | last post by:
Hi there I would like to write a javascript function that creates a drop-down list dynamically. I read on the docs that most HTML controls can not be created on run-time. what kind of...
5
by: TB | last post by:
Hi All: The following is probably a newbie question, but please bear with me: I am populating a drop down list with items from a database, and would the default selected item to be the current...
4
by: Pete Lux | last post by:
I have a drop down that populates on page load. The drop down brings in customer numbers from my local MSDE database. It does this fine, but I click a button that finds quotes for those customers...
2
by: Jim in Arizona | last post by:
My goal, somehow, is to populate a dropdownlist with all the user names in active directory. I don't even know where to begin, really. I added a reference to System.DirectoryServices so I could...
4
by: bryan | last post by:
Hi all, I am working on a .net 2.0 web app. On page load I display a gridview with a drop down list (Employees), when the user selects from the drop down list, the grid view is filled with...
3
by: Yi Chen | last post by:
We have a drop down list on a PHP page, with several product names, and when people click one item, we will refresh the same page with the product name as parameter, and in turn we want to include...
6
by: Rob Meade | last post by:
Hi all, Looking for a bit of help if possible. For about 2 weeks now I've been investigating the best way to populate related drop down menus, and have their values pre-populated again if the...
3
by: DaveRook | last post by:
Hi I am using C# and Access databse for a web site. I have a drop down list which I need to populate dynamically according to results in a database. Example There will be 1 drop down list...
14
by: Philth | last post by:
Hi there, I've essentially got a form with several drop down, each populated by columns in various tables. The populating bit works fine - the column rows appear as they should in the menu. ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.